<?php
$time = microtime(true);
Swoole\Coroutine\run(function () {
    $pdoConifg = new Swoole\Database\PDOConfig();
    $pdoConifg->withHost('124.221.95.45')
        ->withPort('3306')
        ->withUsername('root')
        ->withCharset('utf8mb4')
        ->withPassword('msarLK978')
        ->withDbName('tmp');
    $pool = new Swoole\Database\PDOPool($pdoConifg, 5);

    for($i = 0 ; $i < 5; $i++) {
        go(function () use ($pool) {
           $pdo = $pool->get();
           $statement = $pdo->prepare("SELECT ? + ?");
           $a =  mt_rand(1, 100);
           $b = mt_rand(1, 100);
           $result = $statement->execute([$a, $b]);
            if (!$result) {
                throw new RuntimeException('Execute failed');
            }
            $result = $statement->fetchAll();
            if ($a + $b !== (int)$result[0][0]) {
                throw new RuntimeException('Bad result');
            }
            $pool->put($pdo);
        });
    }
});
echo microtime(true) - $time, PHP_EOL;